home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / asciit1a / form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-07-01  |  8.6 KB  |  274 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  3. Begin VB.Form AsciiTable 
  4.    Caption         =   "Ascii Table"
  5.    ClientHeight    =   5775
  6.    ClientLeft      =   165
  7.    ClientTop       =   735
  8.    ClientWidth     =   7950
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   5775
  11.    ScaleWidth      =   7950
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.ListBox lstAscii2 
  14.       BackColor       =   &H00C0C0C0&
  15.       Columns         =   1
  16.       Height          =   5100
  17.       IntegralHeight  =   0   'False
  18.       ItemData        =   "Form1.frx":0000
  19.       Left            =   120
  20.       List            =   "Form1.frx":0007
  21.       TabIndex        =   1
  22.       Top             =   120
  23.       Width           =   5415
  24.    End
  25.    Begin MSComDlg.CommonDialog comDlg 
  26.       Left            =   6240
  27.       Top             =   2040
  28.       _ExtentX        =   847
  29.       _ExtentY        =   847
  30.       _Version        =   393216
  31.    End
  32.    Begin VB.ListBox lstAscii1 
  33.       BackColor       =   &H00C0C0C0&
  34.       Height          =   5100
  35.       IntegralHeight  =   0   'False
  36.       ItemData        =   "Form1.frx":0016
  37.       Left            =   120
  38.       List            =   "Form1.frx":001D
  39.       TabIndex        =   0
  40.       Top             =   120
  41.       Width           =   5415
  42.    End
  43.    Begin VB.Menu mnuFile 
  44.       Caption         =   "&File"
  45.       Begin VB.Menu mnuConvert 
  46.          Caption         =   "&Ascii Converter"
  47.       End
  48.       Begin VB.Menu mnuGame 
  49.          Caption         =   "Ascii &Game"
  50.          Visible         =   0   'False
  51.       End
  52.       Begin VB.Menu mnuExit 
  53.          Caption         =   "E&xit"
  54.       End
  55.    End
  56.    Begin VB.Menu mnuEdit 
  57.       Caption         =   "&Edit"
  58.       Begin VB.Menu mnuFont 
  59.          Caption         =   "&Font"
  60.          Shortcut        =   ^T
  61.       End
  62.       Begin VB.Menu mnuDisplay 
  63.          Caption         =   "&Display Horizontally"
  64.          Shortcut        =   ^D
  65.       End
  66.       Begin VB.Menu mnuFind 
  67.          Caption         =   "Fi&nd"
  68.          Shortcut        =   ^F
  69.       End
  70.       Begin VB.Menu mnuFindNext 
  71.          Caption         =   "Find Ne&xt"
  72.          Shortcut        =   {F3}
  73.       End
  74.       Begin VB.Menu mnuGoto 
  75.          Caption         =   "&Goto"
  76.          Shortcut        =   ^{F3}
  77.       End
  78.    End
  79.    Begin VB.Menu mnuHelp 
  80.       Caption         =   "&Help"
  81.       Begin VB.Menu mnuAbout 
  82.          Caption         =   "&About"
  83.          Shortcut        =   ^A
  84.       End
  85.    End
  86. Attribute VB_Name = "AsciiTable"
  87. Attribute VB_GlobalNameSpace = False
  88. Attribute VB_Creatable = False
  89. Attribute VB_PredeclaredId = True
  90. Attribute VB_Exposed = False
  91. Option Explicit
  92. Dim gotoLine As Integer, i As Integer, x As Integer, Char As String, findWhat
  93. Private Sub Form_Load()
  94.     mnuFindNext.Enabled = False
  95.     refreshForm
  96.     lstAscii1.Clear
  97.     lstAscii2.Clear
  98.     lstAscii2.Visible = False
  99.     For i = 0 To 255
  100.         listAscii
  101.         lstAscii1.AddItem (i) & Chr(9) & Char
  102.         lstAscii2.AddItem (i) & Chr(9) & Char
  103.     Next i
  104. End Sub
  105. Private Sub Form_Resize()
  106.     refreshForm
  107. End Sub
  108. Private Sub Form_Unload(Cancel As Integer)
  109.     Me.WindowState = 0
  110.     Me.Caption = "Bye Bye"
  111.     Do While Me.Height > 405
  112.         Me.Height = Me.Height - 100
  113.         If Me.Width > 1680 Then
  114.             Me.Width = Me.Width - 100
  115.         End If
  116.     Loop
  117. End Sub
  118. Private Sub mnuAbout_Click()
  119.     frmAbout.Show
  120. End Sub
  121. Private Sub mnuConvert_Click()
  122.     AsciiConvert.Show
  123. End Sub
  124. Private Sub mnuDisplay_Click()
  125.     If mnuDisplay.Caption = "&Display Horizontally" Then
  126.         mnuDisplay.Caption = "&Display Vertically"
  127.         lstAscii2.ListIndex = lstAscii1.ListIndex
  128.         lstAscii1.Visible = False
  129.         lstAscii2.Visible = True
  130.     Else
  131.         mnuDisplay.Caption = "&Display Horizontally"
  132.         lstAscii1.ListIndex = lstAscii2.ListIndex
  133.         lstAscii1.Visible = True
  134.         lstAscii2.Visible = False
  135.     End If
  136. End Sub
  137. Private Sub mnuExit_Click()
  138.     Unload Me
  139. End Sub
  140. Private Sub mnuFind_Click()
  141.     findWhat = InputBox("Find what:")
  142.     If findWhat = "" Then
  143.         mnuFindNext.Enabled = False
  144.     Else
  145.         mnuFindNext.Enabled = True
  146.         findNow
  147.     End If
  148. End Sub
  149. Private Sub mnuFindNext_Click()
  150.     findNow
  151. End Sub
  152. Private Sub mnuFont_Click()
  153.     comDlg.Min = 6
  154.     comDlg.Max = 14
  155.     comDlg.Flags = cdlCFApply Or cdlCFBoth Or cdlCFLimitSize
  156.     comDlg.ShowFont
  157.     lstAscii1.Font = comDlg.FontName
  158.     lstAscii1.FontSize = comDlg.FontSize
  159.     lstAscii2.Font = comDlg.FontName
  160.     lstAscii2.FontSize = comDlg.FontSize
  161. End Sub
  162. Private Sub mnuGame_Click()
  163.     AsciiGame.Show
  164. End Sub
  165. Private Sub mnuGoto_Click()
  166.     On Error GoTo ErrorHandler
  167.     gotoLine = InputBox("Goto line:" & Chr(13) & "Enter a number")
  168.     If gotoLine >= 0 And gotoLine <= 255 Then
  169.         lstAscii1.ListIndex = gotoLine
  170.         lstAscii2.ListIndex = gotoLine
  171.     Else
  172.         MsgBox ("You must enter a line number to go to")
  173.     End If
  174.     Exit Sub
  175. ErrorHandler:
  176.     Select Case Err.Number
  177.         Case 55
  178.             Close #1
  179.         Case Else
  180.     End Select
  181.     Resume
  182. End Sub
  183. Sub findNow()
  184.     If IsNumeric(findWhat) = True Then
  185.         If findWhat >= 10 And findWhat <= 255 Then
  186.             MsgBox ("Use 'Goto' to find an ascii character by ascii code")
  187.         ElseIf findWhat >= 0 And findWhat <= 9 Then
  188.             lstAscii1.ListIndex = Asc(findWhat)
  189.             lstAscii2.ListIndex = Asc(findWhat)
  190.         Else
  191.             MsgBox ("Enter a number between 0 and 9")
  192.         End If
  193.     ElseIf Len(findWhat) = 1 Then
  194.         lstAscii1.ListIndex = Asc(findWhat)
  195.         lstAscii2.ListIndex = Asc(findWhat)
  196.     Else
  197.         If LCase(findWhat) = "game" Or LCase(findWhat) = "play" Or LCase(findWhat) = "playgame" Or LCase(findWhat) = "play game" Then
  198.             MsgBox ("Click on File, then Game to play the Ascii Game")
  199.             AsciiTable.mnuGame.Visible = True
  200.         ElseIf LCase(findWhat) = "backspace" Or LCase(findWhat) = "back space" Then
  201.             lstAscii1.ListIndex = 8
  202.             lstAscii2.ListIndex = 8
  203.         ElseIf LCase(findWhat) = "tab" Then
  204.             lstAscii1.ListIndex = 9
  205.             lstAscii2.ListIndex = 9
  206.         ElseIf LCase(findWhat) = "linefeed" Or LCase(findWhat) = "line feed" Then
  207.             lstAscii1.ListIndex = 10
  208.             lstAscii2.ListIndex = 10
  209.         ElseIf LCase(findWhat) = "carriagereturn" Or LCase(findWhat) = "carriage return" Then
  210.             lstAscii1.ListIndex = 13
  211.             lstAscii2.ListIndex = 13
  212.         ElseIf LCase(findWhat) = "undo" Then
  213.             lstAscii1.ListIndex = 26
  214.             lstAscii2.ListIndex = 26
  215.         ElseIf LCase(findWhat) = "space" Then
  216.             If lstAscii1.ListIndex = 31 Or lstAscii2.ListIndex = 32 Then
  217.                 lstAscii1.ListIndex = 160
  218.                 lstAscii2.ListIndex = 160
  219.             Else
  220.                 lstAscii1.ListIndex = 32
  221.                 lstAscii2.ListIndex = 32
  222.             End If
  223.         End If
  224.     End If
  225. End Sub
  226. Sub listAscii()
  227.     Char = Chr(i)
  228.     If i >= 0 And i <= 7 Or i = 11 Or i = 12 Or i >= 14 And i <= 25 Or i >= 27 And i <= 31 Or i = 127 Then
  229.         Char = Char & Chr(9) & Chr(9) & Chr(9) & "Not supported by Microsoft Windows"
  230.     ElseIf i = 8 Then
  231.         Char = Char & Chr(9) & "Back space"
  232.     ElseIf i = 9 Then
  233.         Char = Char & "Tab"
  234.     ElseIf i = 10 Then
  235.         Char = Char & Chr(9) & "Line feed"
  236.     ElseIf i = 13 Then
  237.         Char = Char & Chr(9) & "Carriage return"
  238.     ElseIf i = 22 Then
  239.         Char = Char & Chr(9) & "Paste" & Chr(9) & Chr(9) & "Not supported by Microsoft Windows"
  240.     ElseIf i = 26 Then
  241.         Char = Char & Chr(9) & "Undo" & Chr(9) & Chr(9) & "Not supported by Microsoft Windows"
  242.     ElseIf i = 32 Or i = 160 Then
  243.         Char = Char & Chr(9) & "Space"
  244.     ElseIf i >= 48 And i <= 57 Then
  245.         Char = Char & Chr(9) & "Numbers"
  246.     ElseIf i >= 65 And i <= 90 Then
  247.         Char = Char & Chr(9) & "Uppercase alphabet"
  248.     ElseIf i >= 97 And i <= 122 Then
  249.         Char = Char & Chr(9) & "Lowercase alphabet"
  250.     End If
  251. End Sub
  252. Sub refreshForm()
  253.     With lstAscii1
  254.         If Me.Height > 885 Then
  255.             .Height = Me.Height - 885
  256.         End If
  257.         .Left = 120
  258.         .Top = 120
  259.         If Me.Width > 360 Then
  260.             .Width = Me.Width - 360
  261.         End If
  262.     End With
  263.     With lstAscii2
  264.         If Me.Height > 885 Then
  265.             .Height = Me.Height - 885
  266.         End If
  267.         .Left = 120
  268.         .Top = 120
  269.         If Me.Width > 360 Then
  270.             .Width = Me.Width - 360
  271.         End If
  272.     End With
  273. End Sub
  274.